package com.elysia.newsservice.controller;

import com.elysia.newsservice.domain.dto.GameStatisticDTO;
import com.elysia.newsservice.domain.vo.GameStatisticVO;
import com.elysia.newsservice.result.Result;
import com.elysia.newsservice.service.impl.IGameStatisticServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/game-statistic")
@RequiredArgsConstructor
@Slf4j
public class GameStatisticController {
    private final IGameStatisticServiceImpl gameStatisticService;
    @GetMapping(value = "/all")
    public Result<List<GameStatisticVO>> getAllGameStatistics() {
        log.info("获取全部统计项");
        return gameStatisticService.getAllGameStatistic();
    }
    /**
     * 添加统计项
     * @param gameStatisticDTO 添加的统计项信息
     */
    @PostMapping
    public Result<GameStatisticVO> addGameStatistic(@RequestBody GameStatisticDTO gameStatisticDTO) {
        log.info("添加统计项{}", gameStatisticDTO);
        return gameStatisticService.addGameStatistic(gameStatisticDTO);
    }
    /**
     * 更新统计项
     * @param gameStatisticDTO 更新的统计项信息
     */
    @PutMapping("/{id}")
    public Result<GameStatisticVO> updateGameStatistic(@PathVariable Long id, @RequestBody GameStatisticDTO gameStatisticDTO) {
        log.info("更新统计项{}: {}",  id, gameStatisticDTO);
        return gameStatisticService.updateGameStatistic(id, gameStatisticDTO);
    }
}
